/*     */ package com.java.diagnostics.visualizer.parser.vgc.j926;
/*     */ 
/*     */ import com.java.diagnostics.visualizer.data.DataLevel;
/*     */ import com.java.diagnostics.visualizer.data.SourceData;
/*     */ import com.java.diagnostics.visualizer.data.StructuredDataBuilder;
/*     */ import com.java.diagnostics.visualizer.data.UnstructuredData;
/*     */ import com.java.diagnostics.visualizer.exceptions.GCAndMemoryVisualizerException;
/*     */ import com.java.diagnostics.visualizer.exceptions.GCAndMemoryVisualizerParsedDataCorruptedException;
/*     */ import com.java.diagnostics.visualizer.factory.DataFactory;
/*     */ import com.java.diagnostics.visualizer.factory.SourceDataFactory;
/*     */ import com.java.diagnostics.visualizer.gc.defaultextensions.util.Messages;
/*     */ import com.java.diagnostics.visualizer.parser.vgc.VGCDataManager;
/*     */ import com.java.diagnostics.visualizer.parser.vgc.constants.VGCGCReasons;
/*     */ import com.java.diagnostics.visualizer.parser.vgc.constants.VGCGCScopes;
/*     */ import com.java.diagnostics.visualizer.parser.vgc.constants.WRTEvents;
/*     */ import com.java.diagnostics.visualizer.parser.vgc.constants.WRTQuantumTypes;
/*     */ import com.java.diagnostics.visualizer.parser.vgc.j9.FriendlyXMLParser;
/*     */ import com.java.diagnostics.visualizer.parser.xml.VGCXMLParser;
/*     */ import com.java.diagnostics.visualizer.properties.OutputProperties;
/*     */ import com.java.diagnostics.visualizer.sources.Source;
/*     */ import java.io.IOException;
/*     */ import java.text.MessageFormat;
/*     */ import javax.xml.parsers.ParserConfigurationException;
/*     */ import org.xml.sax.Attributes;
/*     */ import org.xml.sax.SAXException;
/*     */ import org.xml.sax.SAXParseException;
/*     */ 
/*     */ public class InstanceJ926VGCParser extends VGCXMLParser
/*     */ {
/*     */   private static final String EXCLUSIVE_END = "exclusive-end";
/*     */   private static final String AF_START = "af-start";
/*     */   private static final String AF_END = "af-end";
/*     */   private static final String GCOP = "gc-op";
/*     */   private static final String BYTES_REQUESTED = "totalBytesRequested";
/*     */   private static final String TIMEMS = "timems";
/*     */   private static final String CLASSUNLOAD = "classunload";
/*     */   private static final String REFERENCES = "references";
/*     */   private static final String CLEARED = "cleared";
/*     */   private static final String COMPACT_INFO = "compact-info";
/*     */   private static final String REASON = "reason";
/*     */   private static final String RESPONSE_INFO = "response-info";
/*     */   private static final String CONCURRENT_KICKOFF = "concurrent-kickoff";
/*     */   private static final String KICKOFF = "kickoff";
/*     */   private static final String TARGET_BYTES = "targetBytes";
/*     */   private static final String THRESHOLD_FREE_BYTES = "thresholdFreeBytes";
/*     */   private static final String CON_CARD_CLEANING = "concurrent-card-cleaning";
/*     */   private static final String CARD_CLEANING = "card-cleaning";
/*     */   private static final String CARDS_CLEANED = "cardsCleaned";
/*     */   private static final String BYTES_TRACED = "bytesTraced";
/*     */   private static final String DURATION = "duration";
/*     */   private static final String DURATIONMS = "durationms";
/*     */   private static final String MEMORY_COPIED = "memory-copied";
/*     */   private static final String TENURE = "tenure";
/*     */   private static final String OBJECTS = "objects";
/*     */   private static final String COPY_FAILED = "copy-failed";
/*     */   private static final String MEM_INFO = "mem-info";
/*     */   private static final String MEM = "mem";
/*     */   private static final String CONCURRENT_COLLECTION_START = "concurrent-collection-start";
/*     */   private static final String CONCURRENT_COLLECTION_END = "concurrent-collection-end";
/*     */   private static final String FREE = "free";
/*     */   private static final String CLASSES_INFO = "classunload-info";
/*     */   private static final String CYCLE_START = "cycle-start";
/*     */   private static final String CYCLE_END = "cycle-end";
/*     */   private static final String GC_START = "gc-start";
/*     */   private static final String GC_END = "gc-end";
/*     */   private static final String CANDIDATES = "candidates";
/*     */   private static final String ENQUEUED = "enqueued";
/*     */   private static final String DYNAMIC_THRESHOLD = "dynamicThreshold";
/*     */   private static final String MAX_THRESHOLD = "maxThreshold";
/*     */   private static final String SCAVENGER_INFO = "scavenger-info";
/*     */   private static final String SYS_START = "sys-start";
/*     */   private static final String SYS_END = "sys-end";
/*     */   private static final String AF_SATISFIED = "allocation-satisfied";
/*     */   private static final String AF_UNSATISFIED = "allocation-unsatisfied";
/*     */   private static final String EDEN = "eden";
/*     */   private static final String REMEMBERED_SET = "remembered-set";
/*     */   private static final String ALLOCATION_TAXATION = "allocation-taxation";
/*     */   private static final String NUMA = "numa";
/*     */   private static final String COMMON = "common";
/*     */   private static final String LOCAL = "local";
/*     */   private static final String NON_LOCAL = "non-local";
/*     */   private static final String NON_LOCAL_PERCENT = "non-local-percent";
/*     */   private static final String ARRAYLET_PRIMITIVE = "arraylet-primitive";
/*     */   private static final String ARRAYLET_REFERENCE = "arraylet-reference";
/*     */   private static final String GMP = "global mark phase";
/*     */   private static final String LEAVES = "leaves";
/*     */   private static final String LARGEST = "largest";
/*     */   private static final double MICRO_SEC_PER_MS = 1000.0D;
/*     */   private static final String MARK_INVOKED = "Mark invoked";
/*     */   private static final String OPERATION_ABORTED = "operation aborted";
/*     */   private static final String COPY_FORWARD = "copy forward";
/*     */   private static final String COMMA = ", ";
/*     */   private static final String OTHER = "other";
/*     */   private static final String ALLOCATED_BYTES = "allocated-bytes";
/*     */   private static final String ARRAYLET_LEAF = "arrayletleaf";
/*     */   private static final String PERCOLATE = "percolate-collect";
/*     */   private static final String SYNCGC = "syncgc";
/*     */   private static final String HEARTBEAT = "heartbeat";
/*     */   private static final String EXCLUSIVE_INFO = "exclusiveaccess-info";
/*     */   private static final String MIN_TIME_MS = "minTimeMs";
/*     */   private static final String MAX_TIME_MS = "maxTimeMs";
/*     */   private static final String MEAN_TIME_MS = "meanTimeMs";
/*     */   private static final String FREE_MEM = "free-mem";
/*     */   private static final String IMMORTAL = "immortal";
/*     */   private static final String HEAP = "heap";
/*     */   private static final String MIN_BYTES = "minBytes";
/*     */   private static final String MAX_BYTES = "meanBytes";
/*     */   private static final String MEAN_BYTES = "meanBytes";
/*     */   private static final String QUANTA = "quanta";
/*     */   private static final String QUANTUM_COUNT = "quantumCount";
/*     */   private static final String SYNCGC_INFO = "syncgc-info";
/*     */   private static final String THREAD_PRIORITY = "thread-priority";
/*     */   private static final String MIN_PRIORITY = "minPriority";
/*     */   private static final String MAX_PRIORITY = "maxPriority";
/*     */   private static final String TRIGGER_START = "trigger-start";
/*     */   private static final String TRIGGER_END = "trigger-end";
/*     */   private static final String FREE_MEM_DELTA = "free-mem-delta";
/*     */   private static final String BYTES_BEFORE = "bytesBefore";
/*     */   private static final String BYTES_AFTER = "bytesAfter";
/*     */   private static final String QUANTUM_TYPE = "quantumType";
/* 142 */   private boolean inMemInfo = false;
/* 143 */   private boolean inCardCleaning = false;
/* 144 */   private boolean inGCStart = false;
/* 145 */   private boolean inGCEnd = false;
/* 146 */   private boolean inScavenge = false;
/* 147 */   private boolean createdAmountTenured = false;
/* 148 */   private boolean isGencon = false;
/* 149 */   private boolean inConcurrentKickoff = false;
/* 150 */   private int currentReason = -1;
/*     */   private double triggeredInterval;
/*     */   private double miniInterval;
/* 153 */   private double bytesRequested = -1.0D;
/*     */   private double accessTime;
/*     */   private double free;
/*     */   private double total;
/* 157 */   private boolean storedMemory = false;
/* 158 */   private int increments = 0;
/* 159 */   private boolean hadWarning = false;
/* 160 */   private double gmpStartTime = 0.0D;
/* 161 */   private double triggerStart = -1.0D;
/* 162 */   private double syncDuration = -1.0D;
/*     */   private Source source;
/* 165 */   private boolean hadGCStart = false;
/*     */ 
/*     */   public SourceData parse(Source source, OutputProperties properties)
/*     */     throws GCAndMemoryVisualizerException
/*     */   {
/* 181 */     this.source = source;
/* 182 */     this.properties = properties;
/* 183 *          initialisePreferences();
/*     */ 
/* 186 */     String variantIdentifier = source.getVariantIdentifier();
/* 187 */     this.sourceData = SOURCE_DATA_FACTORY.createSourceData(variantIdentifier);
/* 188 */     this.dataManager = new VGCDataManager(source, this.sourceData, properties);
/* 189 */     initialiseAttributeData();
/*     */     try {
/* 191 */       FriendlyXMLParser parser = new FriendlyXMLParser();
/* 192 */       parser.parse(source, this);
/*     */     }
/*     */     catch (SAXParseException e)
/*     */     {
/* 200 */       if (new J926VGCParser().isParseableSource(source))
/* 201 */         throw new GCAndMemoryVisualizerParsedDataCorruptedException(
/* 203 */           Messages.getString(
/* 204 */           "GCAndMemoryVisualizerXMLParser.badly.formed.xml", 
/* 205 */           new Object[] { e.getMessage() }), e
/* 206 */           .getLineNumber(), e.getColumnNumber(), 
/* 207 */           source.getName());
/*     */     }
/*     */     catch (SAXException se)
/*     */     {
/* 211 */       throw new GCAndMemoryVisualizerException(se);
/*     */     }
/*     */     catch (ParserConfigurationException pe) {
/* 214 */       throw new GCAndMemoryVisualizerException(pe);
/*     */     }
/*     */     catch (IOException ioe) {
/* 217 */       throw new GCAndMemoryVisualizerException(ioe);
/*     */     }
/*     */     catch (Exception e) {
/* 220 */       throw new GCAndMemoryVisualizerException(e);
/*     */     }
/* 222 */     return this.sourceData;
/*     */   }
/*     */ 
/*     */   public void startElement(String uri, String localName, String name, Attributes atts)
/*     */   {
/* 228 */     if (name != null)
/* 229 */       if ("file".equals(name))
/*     */       {
/* 231 */         initialiseGeneralSourceData(this.source, this.properties);
/* 232 */       } else if ("verbosegc".equals(name)) {
/* 233 */         handleVerboseStart(name, atts);
/* 234 */       } else if ("exclusive-end".equals(name)) {
/* 235 */         handleExclusiveEnd(name, atts);
/* 236 */       } else if ("af-start".equals(name)) {
/* 237 */         handleAFStart(name, atts);
/* 238 */       } else if ("gc-op".equals(name)) {
/* 239 */         handleGCOP(name, atts);
/* 240 */       } else if ("references".equals(name)) {
/* 241 */         handleReferences(name, atts);
/* 242 */       } else if ("compact-info".equals(name)) {
/* 243 */         handleCompactInfo(name, atts);
/* 244 */       } else if ("response-info".equals(name)) {
/* 245 */         handleResponseInfo(name, atts);
/* 246 */       } else if ("concurrent-kickoff".equals(name)) {
/* 247 */         this.inConcurrentKickoff = true;
/* 248 */       } else if ("kickoff".equals(name)) {
/* 249 */         handleKickoff(name, atts);
/* 250 */       } else if ("concurrent-card-cleaning".equals(name)) {
/* 251 */         this.inCardCleaning = true;
/* 252 */       } else if ("card-cleaning".equals(name)) {
/* 253 */         handleCardCleaning(name, atts);
/* 254 */       } else if ("duration".equals(name)) {
/* 255 */         handleDuration(name, atts);
/* 256 */       } else if ("memory-copied".equals(name)) {
/* 257 */         handleMemoryCopied(name, atts);
/* 258 */       } else if ("copy-failed".equals(name)) {
/* 259 */         handleCopyFailed(name, atts);
/* 260 */       } else if ("mem-info".equals(name)) {
/* 261 */         handleMemInfo(name, atts);
/* 262 */         this.inMemInfo = true;
/* 263 */       } else if ("mem".equals(name))
/*     */       {
/* 265 */         handleMemory(name, atts);
/* 266 */       } else if ("concurrent-collection-start".equals(name)) {
/* 267 */         handleConcurrentStart(name, atts);
/* 268 */       } else if ("cycle-start".equals(name)) {
/* 269 */         handleCycleStart(name, atts);
/* 270 */       } else if ("classunload-info".equals(name)) {
/* 271 */         handleClassUnload(name, atts);
/* 272 */       } else if (("finalization".equals(name)) && (!this.inMemInfo)) {
/* 273 */         handleFinalization(name, atts);
/* 274 */       } else if ("scavenger-info".equals(name)) {
/* 275 */         handleScavengerInfo(name, atts);
/* 276 */       } else if ("gc-start".equals(name)) {
/* 277 */         this.inGCStart = true;
/* 278 */         handleGCStart(name, atts);
/* 279 */       } else if ("gc-end".equals(name)) {
/* 280 */         this.inGCEnd = true;
/* 281 */         this.storedMemory = false;
/* 282 */         handleGCEnd(name, atts);
/* 283 */       } else if ("sys-start".equals(name)) {
/* 284 */         handleSysStart(name, atts);
/* 285 */       } else if ("allocation-satisfied".equals(name)) {
/* 286 */         handleAFSatisfied(name, atts);
/* 287 */       } else if ("allocation-unsatisfied".equals(name)) {
/* 288 */         handleAFUnSatisfied(name, atts);
/* 289 */       } else if (("af-end".equals(name)) || 
/* 290 */         ("concurrent-collection-end".equals(name)) || 
/* 291 */         ("sys-end".equals(name)))
/*     */       {
/* 293 */         this.currentReason = -1;
/* 294 */       } else if ("remembered-set".equals(name)) {
/* 295 */         handleRememberedSet(name, atts);
/* 296 */       } else if ("allocation-taxation".equals(name)) {
/* 297 */         handleAllocationTaxation(name, atts);
/* 298 */       } else if ("attribute".equals(name)) {
/* 299 */         if (this.inSystemAttributes)
/* 300 */           handleSystemAttribute(name, atts);
/*     */         else
/* 302 */           handleGCAttribute(name, atts);
/*     */       }
/* 304 */       else if ("system".equals(name)) {
/* 305 */         this.inSystemAttributes = true;
/* 306 */       } else if ("numa".equals(name)) {
/* 307 */         handleNuma(name, atts);
/* 308 */       } else if ("arraylet-primitive".equals(name)) {
/* 309 */         handlePrimitiveArraylets(name, atts);
/* 310 */       } else if ("arraylet-reference".equals(name)) {
/* 311 */         handleReferenceArraylets(name, atts);
/* 312 */       } else if ("cycle-end".equals(name)) {
/* 313 */         handleCycleEnd(name, atts);
/* 314 */       } else if ("warning".equals(name)) {
/* 315 */         handleWarning(name, atts);
/* 316 */       } else if ("allocated-bytes".equals(name)) {
/* 317 */         handleAllocatedBytes(name, atts);
/* 318 */       } else if ("percolate-collect".equals(name)) {
/* 319 */         handlePercolate(name, atts);
/* 320 */       } else if ("exclusiveaccess-info".equals(name)) {
/* 321 */         handleExclusiveInfo(name, atts);
/* 322 */       } else if ("free-mem".equals(name)) {
/* 323 */         handleFreeMemory(name, atts);
/* 324 */       } else if ("quanta".equals(name)) {
/* 325 */         handleQuanta(name, atts);
/* 326 */       } else if ("syncgc-info".equals(name)) {
/* 327 */         handleSyncInfo(name, atts);
/* 328 */       } else if ("thread-priority".equals(name)) {
/* 329 */         handleThreadPriority(name, atts);
/* 330 */       } else if ("trigger-start".equals(name)) {
/* 331 */         handleTriggerStart(name, atts);
/* 332 */       } else if ("trigger-end".equals(name)) {
/* 333 */         handleTriggerEnd(name, atts);
/* 334 */       } else if ("free-mem-delta".equals(name)) {
/* 335 */         handleFreeMemDelta(name, atts);
/*     */       }
/*     */   }
/*     */ 
/*     */   private void handleFreeMemDelta(String name, Attributes atts)
/*     */   {
/* 341 */     String type = atts.getValue("type");
/* 342 */     if ("heap".equals(type)) {
/* 343 */       addAttribute("WRTLabels.free.heap.cycles", "bytesBefore", atts);
/* 344 */       double current = this.dataManager.getCurrentX();
/* 345 */       this.dataManager.setX(current + this.syncDuration);
/* 346 */       addAttribute("WRTLabels.free.heap.cycles", "bytesAfter", atts);
/*     */     }
/*     */   }
/*     */ 
/*     */   private void handleTriggerEnd(String name, Attributes atts) {
/* 351 */     double timeStamp = convertStringToNumber(atts.getValue("timestamp"));
/* 352 */     if (this.triggerStart > 0.0D) {
/* 353 */       double duration = timeStamp - this.triggerStart;
/* 354 */       addDataPoint("WRTLabels.trigger.durations", duration, this.currentComment);
/*     */     }
/* 356 */     addDataPoint("WRTLabels.gc.activity", WRTEvents.nameToInt(name), 
/* 357 */       this.currentComment);
/*     */   }
/*     */ 
/*     */   private void handleTriggerStart(String name, Attributes atts)
/*     */   {
/* 362 */     double timeStamp = convertStringToNumber(atts.getValue("timestamp"));
/* 363 */     this.dataManager.setX(timeStamp);
/*     */ 
/* 365 */     this.triggerStart = timeStamp;
/* 366 */     addDataPoint("WRTLabels.gc.activity", WRTEvents.nameToInt(name), 
/* 367 */       this.currentComment);
/*     */   }
/*     */ 
/*     */   private void handleThreadPriority(String name, Attributes atts)
/*     */   {
/* 372 */     addAttribute("WRTLabels.min.gc.thread.priority", "minPriority", atts);
/* 373 */     addAttribute("WRTLabels.max.gc.thread.priority", "maxPriority", atts);
/*     */   }
/*     */ 
/*     */   private void handleSyncInfo(String name, Attributes atts) {
/* 377 */     String reason = atts.getValue("reason");
/*     */ 
/* 379 */     addDataPoint("WRTLabels.gc.activity", WRTEvents.nameToInt(reason), 
/* 380 */       this.currentComment);
/*     */   }
/*     */ 
/*     */   private void handleQuanta(String name, Attributes atts) {
/* 384 */     addAttribute("WRTLabels.min.gc.quantum.time", "minTimeMs", atts);
/* 385 */     addAttribute("WRTLabels.max.gc.quantum.time", "maxTimeMs", atts);
/* 386 */     addAttribute("WRTLabels.mean.gc.quantum.time", "meanTimeMs", atts);
/* 387 */     addAttribute("WRTLabels.quanta.per.heartbeat", "quantumCount", atts);
/*     */ 
/* 389 */     String type = atts.getValue("quantumType");
/* 390 */     addDataPoint("WRTLabels.quantum.type", WRTQuantumTypes.nameToInt(type), 
/* 391 */       this.currentComment);
/*     */   }
/*     */ 
/*     */   private void handleFreeMemory(String name, Attributes atts) {
/* 395 */     String type = atts.getValue("type");
/* 396 */     if ("heap".equals(type)) {
/* 397 */       addAttribute("WRTLabels.free.heap.min", "minBytes", atts);
/* 398 */       addAttribute("WRTLabels.free.heap.max", "meanBytes", atts);
/* 399 */       addAttribute("WRTLabels.free.heap.mean", "meanBytes", atts);
/* 400 */     } else if ("immortal".equals(type)) {
/* 401 */       addAttribute("WRTLabels.free.immortal.min", "minBytes", atts);
/* 402 */       addAttribute("WRTLabels.free.immortal.max", "meanBytes", atts);
/* 403 */       addAttribute("WRTLabels.free.immortal.mean", "meanBytes", atts);
/*     */     }
/*     */   }
/*     */ 
/*     */   private void handleExclusiveInfo(String name, Attributes atts) {
/* 408 */     addAttribute("WRTLabels.min.exclusive.access", "minTimeMs", atts);
/* 409 */     addAttribute("WRTLabels.max.exclusive.access", "maxTimeMs", atts);
/* 410 */     addAttribute("WRTLabels.mean.exclusive.access", "meanTimeMs", atts);
/*     */   }
/*     */ 
/*     */   private void handlePercolate(String name, Attributes atts) {
/* 414 */     addDataPoint("VGCLabels.gc.percolated", 1.0D, this.currentComment);
/*     */   }
/*     */ 
/*     */   private void handleAllocatedBytes(String name, Attributes atts) {
/* 418 */     addAttribute("VGCLabels.arraylet.leaf", "arrayletleaf", atts);
/*     */   }
/*     */ 
/*     */   private void handleWarning(String name, Attributes atts) {
/* 422 */     String details = atts.getValue("details");
/* 423 */     if (details != null)
/* 424 */       if (details.startsWith("Mark invoked")) {
/* 425 */         this.hadWarning = true;
/* 426 */         this.dataManager.updateLastComment("VGCLabels.mark.times", ", " + 
/* 427 */           details);
/* 428 */       } else if (details.startsWith("operation aborted")) {
/* 429 */         this.hadWarning = true;
/* 430 */         this.dataManager.updateLastComment("VGCLabels.copy.forward.time", 
/* 431 */           ", " + details);
/*     */       }
/*     */   }
/*     */ 
/*     */   private void handleReferenceArraylets(String name, Attributes atts)
/*     */   {
/* 439 */     if (this.inGCStart) {
/* 440 */       addAttribute("VGCLabels.reference.arraylet.largest.object", "largest", 
/* 441 */         atts);
/* 442 */       addAttribute("VGCLabels.reference.arraylet.leaves", "leaves", atts);
/* 443 */       addAttribute("VGCLabels.reference.arraylet.objects", "objects", atts);
/*     */     }
/*     */   }
/*     */ 
/*     */   private void handlePrimitiveArraylets(String name, Attributes atts)
/*     */   {
/* 449 */     if (this.inGCStart) {
/* 450 */       addAttribute("VGCLabels.primitive.arraylet.largest.object", "largest", 
/* 451 */         atts);
/* 452 */       addAttribute("VGCLabels.primitive.arraylet.leaves", "leaves", atts);
/* 453 */       addAttribute("VGCLabels.primitive.arraylet.objects", "objects", atts);
/*     */     }
/*     */   }
/*     */ 
/*     */   private void handleNuma(String name, Attributes atts) {
/* 458 */     if (this.inGCStart) {
/* 459 */       addAttribute("VGCLabels.common.numa.start", "common", atts);
/* 460 */       addAttribute("VGCLabels.local.numa.start", "local", atts);
/* 461 */       addAttribute("VGCLabels.non.local.numa.start", "non-local", atts);
/* 462 */       addAttribute("VGCLabels.non.local.percent.numa", "non-local-percent", 
/* 463 */         atts);
/*     */     } else {
/* 465 */       addAttribute("VGCLabels.common.numa.end", "common", atts);
/* 466 */       addAttribute("VGCLabels.local.numa.end", "local", atts);
/* 467 */       addAttribute("VGCLabels.non.local.numa.end", "non-local", atts);
/*     */     }
/*     */   }
/*     */ 
/*     */   private void handleRememberedSet(String name, Attributes atts)
/*     */   {
/* 473 */     if (this.inGCStart) {
/* 474 */       addAttribute("VGCLabels.total.remembered.set", "total", atts);
/* 475 */       addAttribute("VGCLabels.free.remembered.set", "free", atts);
/*     */     }
/*     */   }
/*     */ 
/*     */   private void handleAFUnSatisfied(String name, Attributes atts) {
/* 480 */     addDataPoint("VGCLabels.af.success", 0.0D, this.currentComment);
/*     */   }
/*     */ 
/*     */   private void handleAFSatisfied(String name, Attributes atts) {
/* 484 */     addDataPoint("VGCLabels.af.success", 1.0D, this.currentComment);
/*     */   }
/*     */ 
/*     */   private void handleGCEnd(String name, Attributes atts) {
/* 488 */     double pauseTime = convertStringToNumber(atts.getValue("durationms"));
/* 489 */     addDataPoint("VGCLabels.pause.times.without.exclusive.access", pauseTime, 
/* 490 */       this.currentComment);
/* 491 */     if (this.hadWarning) {
/* 492 */       addDataPoint("VGCLabels.partial.warnings", pauseTime, this.currentComment);
/* 493 */       this.hadWarning = false;
/*     */     }
/*     */   }
/*     */ 
/*     */   private void handleMemInfo(String name, Attributes atts) {
/* 498 */     this.free = convertStringToNumber(atts.getValue("free"));
/* 499 */     this.total = convertStringToNumber(atts.getValue("total"));
/*     */   }
/*     */ 
/*     */   private void handleCycleStart(String name, Attributes atts) {
/* 503 */     this.miniInterval = convertStringToNumber(atts.getValue("intervalms"));
/* 504 */     String type = atts.getValue("type");
/* 505 */     if ("global mark phase".equals(type)) {
/* 506 */       this.increments = 0;
/* 507 */       this.gmpStartTime = convertStringToNumber(atts.getValue("timestamp"));
/*     */     }
/*     */   }
/*     */ 
/*     */   private void handleCycleEnd(String name, Attributes atts) {
/* 512 */     String type = atts.getValue("type");
/* 513 */     if ("global mark phase".equals(type)) {
/* 514 */       addDataPoint("VGCLabels.gmp.collections", this.increments, this.currentComment);
/* 515 */       if (this.gmpStartTime != 0.0D) {
/* 516 */         double gmpEndTime = convertStringToNumber(
/* 517 */           atts.getValue("timestamp"));
/* 518 */         addDataPoint("VGCLabels.gmp.cycle.time", 
/* 519 */           gmpEndTime - this.gmpStartTime, this.currentComment);
/*     */       }
/*     */     }
/*     */   }
/*     */ 
/*     */   private void handleConcurrentStart(String name, Attributes atts) {
/* 525 */     this.currentReason = VGCGCReasons.CON_INT;
/* 526 */     this.triggeredInterval = convertStringToNumber(atts.getValue("intervalms"));
/*     */   }
/*     */ 
/*     */   private void handleVerboseStart(String name, Attributes atts) {
/* 530 */     if (this.dataManager.getCurrentX() > -1.0D) {
/* 531 */       this.restartCount += 1;
/* 532 */       addDataPoint("VGCLabels.jvm.restarts", 1.0D, "");
/*     */     }
/*     */ 
/* 535 */     this.version = ("IBM J9 " + atts.getValue("version"));
/*     */   }
/*     */ 
/*     */   private void handleScavengerInfo(String name, Attributes atts) {
/* 539 */     addAttribute("VGCLabels.tenure.age", "tenureage", atts);
/* 540 */     addAttribute("VGCLabels.tilt.ratio", "tiltratio", atts);
/*     */   }
/*     */ 
/*     */   private void handleFinalization(String name, Attributes atts) {
/* 544 */     addAttribute("VGCLabels.objects.queued.for.finalization", "enqueued", atts);
/*     */   }
/*     */ 
/*     */   private void handleClassUnload(String name, Attributes atts) {
/* 548 */     addAttribute("VGCLabels.class.loaders.unloaded", "classloadersunloaded", 
/* 549 */       atts);
/* 550 */     addAttribute("VGCLabels.classes.unloaded", "classesunloaded", atts);
/*     */   }
/*     */ 
/*     */   private void handleGCStart(String name, Attributes atts) {
/* 554 */     this.isGoodData = true;
/* 555 */     this.storedMemory = false;
/* 556 */     this.hadGCStart = true;
/* 557 */     double timeStamp = convertStringToNumber(atts.getValue("timestamp"));
/* 558 */     this.dataManager.setX(timeStamp);
/*     */ 
/* 560 */     String type = atts.getValue("type");
/* 561 */     if ("global mark phase".equals(type)) {
/* 562 */       this.increments += 1;
/*     */     }
/*     */ 
/* 565 */     int scope = VGCGCScopes.nameToInt(type);
/*     */ 
/* 567 */     this.currentComment = REASON_COMMENT
/* 568 */       .format(new Object[] { 
/* 568 */       VGCGCReasons.intToName(this.currentReason) });
/*     */ 
/* 570 */     this.currentComment = 
/* 571 */       (this.currentComment + SCOPE_COMMENT
/* 571 */       .format(new Object[] { 
/* 571 */       VGCGCScopes.intToDisplayName(scope) }));
/*     */ 
/* 573 */     addDataPoint("VGCLabels.gc.reasons", this.currentReason, this.currentComment);
/* 574 */     addDataPoint("VGCLabels.gc.scopes", scope, this.currentComment);
/* 575 */     addDataPoint("VGCLabels.gc.intervals", this.miniInterval, this.currentComment);
/* 576 */     addDataPoint("VGCLabels.trigger.intervals", this.triggeredInterval, 
/* 577 */       this.currentComment);
/* 578 */     storeTriggerIntervals();
/* 579 */     addDataPoint("VGCLabels.exclusive.access.times", this.accessTime, 
/* 580 */       this.currentComment);
/*     */ 
/* 582 */     if (this.bytesRequested != -1.0D) {
/* 583 */       this.dataManager.addPoint("VGCLabels.request.sizes.which.triggered.failures", 
/* 584 */         this.bytesRequested, this.currentComment);
/* 585 */       this.bytesRequested = -1.0D;
/*     */     }
/*     */   }
/*     */ 
/*     */   private void storeTriggerIntervals()
/*     */   {
/* 591 */     if (this.currentReason == VGCGCReasons.AF_INT)
/* 592 */       addDataPoint("VGCLabels.af.intervals", this.triggeredInterval, 
/* 593 */         this.currentComment);
/* 594 */     else if (this.currentReason == VGCGCReasons.SYS_INT)
/* 595 */       addDataPoint("VGCLabels.sys.intervals", this.triggeredInterval, 
/* 596 */         this.currentComment);
/* 597 */     else if (this.currentReason == VGCGCReasons.CON_INT)
/* 598 */       addDataPoint("VGCLabels.con.intervals", this.triggeredInterval, 
/* 599 */         this.currentComment);
/* 600 */     else if (this.currentReason == VGCGCReasons.BAL_INT)
/* 601 */       addDataPoint("VGCLabels.at.intervals", this.triggeredInterval, 
/* 602 */         this.currentComment);
/*     */   }
/*     */ 
/*     */   public void endElement(String uri, String localName, String name)
/*     */   {
/* 607 */     if ("file".equals(name))
/*     */     {
/* 609 */       writeOutSourceData();
/* 610 */     } else if ("concurrent-card-cleaning".equals(name)) {
/* 611 */       this.inCardCleaning = false;
/* 612 */     } else if ("mem-info".equals(name)) {
/* 613 */       this.inMemInfo = false;
/*     */     }
/* 615 */     else if ("gc-op".equals(name)) {
/* 616 */       checkAmountTenured();
/* 617 */     } else if ("gc-start".equals(name)) {
/* 618 */       this.inGCStart = false;
/* 619 */       if (!this.storedMemory) {
/* 620 */         addDataPoint("VGCLabels.free.flat.heap.before.gc", this.free, 
/* 621 */           this.currentComment);
/* 622 */         addDataPoint("VGCLabels.total.flat.heap.before.gc", this.total, 
/* 623 */           this.currentComment);
/*     */       }
/* 625 */     } else if ("gc-end".equals(name)) {
/* 626 */       this.inGCEnd = false;
/* 627 */       if (!this.storedMemory) {
/* 628 */         addDataPoint("VGCLabels.free.flat.heap", this.free, 
/* 629 */           this.currentComment);
/* 630 */         addDataPoint("VGCLabels.flat.heap.size", this.total, this.currentComment);
/*     */       }
/*     */     }
/*     */   }
/*     */ 
/*     */   private void checkAmountTenured() {
/* 636 */     if ((this.inScavenge) && (!this.createdAmountTenured)) {
/* 637 */       addDataPoint("VGCLabels.amount.tenured", 0.0D, this.currentComment);
/* 638 */       addDataPoint("VGCLabels.objects.tenured", 0.0D, this.currentComment);
/*     */     }
/* 640 */     this.createdAmountTenured = false;
/* 641 */     this.inScavenge = false;
/*     */   }
/*     */ 
/*     */   private void handleMemory(String name, Attributes atts) {
/* 645 */     if (this.inGCStart)
/* 646 */       parseBeforeGCHeapData(name, atts);
/* 647 */     else if (this.inGCEnd)
/* 648 */       parseAfterGCHeapData(name, atts);
/* 649 */     else if ((this.inConcurrentKickoff) && ("tenured".equals("type")))
/* 650 */       addAttribute("VGCLabels.concurrent.kickoff", "free", atts);
/*     */   }
/*     */ 
/*     */   private void parseAfterGCHeapData(String name, Attributes atts)
/*     */   {
/* 655 */     String type = atts.getValue("type");
/* 656 */     if ("nursery".equals(type)) {
/* 657 */       this.isGencon = true;
/* 658 */       addAttribute("VGCLabels.free.nursery.heap", "free", atts, 
/* 659 */         this.currentComment);
/* 660 */       addAttribute("VGCLabels.nursery.size", "total", atts, this.currentComment);
/* 661 */     } else if ("tenure".equals(type)) {
/* 662 */       if (!this.isGencon) {
/* 663 */         addAttribute("VGCLabels.free.flat.heap", "free", atts, 
/* 664 */           this.currentComment);
/* 665 */         addAttribute("VGCLabels.flat.heap.size", "total", atts, 
/* 666 */           this.currentComment);
/*     */ 
/* 668 */         this.storedMemory = true;
/*     */       } else {
/* 670 */         addAttribute("VGCLabels.free.tenured.heap", "free", atts, 
/* 671 */           this.currentComment);
/* 672 */         addAttribute("VGCLabels.tenured.heap.size", "total", atts, 
/* 673 */           this.currentComment);
/*     */       }
/* 675 */     } else if ("soa".equals(type)) {
/* 676 */       addAttribute("VGCLabels.free.soa.after.collection", "free", atts, 
/* 677 */         this.currentComment);
/* 678 */       addAttribute("VGCLabels.total.soa.after", "total", atts, 
/* 679 */         this.currentComment);
/* 680 */     } else if ("loa".equals(type)) {
/* 681 */       addAttribute("VGCLabels.free.loa.after.collection", "free", atts, 
/* 682 */         this.currentComment);
/* 683 */       addAttribute("VGCLabels.total.loa.after", "total", atts, 
/* 684 */         this.currentComment);
/*     */     }
/*     */   }
/*     */ 
/*     */   private void parseBeforeGCHeapData(String name, Attributes atts) {
/* 689 */     String type = atts.getValue("type");
/* 690 */     if ("nursery".equals(type)) {
/* 691 */       this.isGencon = true;
/* 692 */       addAttribute("VGCLabels.free.nursery.heap.before.gc", "free", atts, 
/* 693 */         this.currentComment);
/* 694 */       addAttribute("VGCLabels.nursery.size.before", "total", atts, 
/* 695 */         this.currentComment);
/* 696 */     } else if ("tenure".equals(type)) {
/* 697 */       if (!this.isGencon) {
/* 698 */         addAttribute("VGCLabels.free.flat.heap.before.gc", "free", atts, 
/* 699 */           this.currentComment);
/* 700 */         addAttribute("VGCLabels.total.flat.heap.before.gc", "total", atts, 
/* 701 */           this.currentComment);
/*     */ 
/* 703 */         this.storedMemory = true;
/*     */       } else {
/* 705 */         addAttribute("VGCLabels.free.tenured.heap.before.gc", "free", atts, 
/* 706 */           this.currentComment);
/* 707 */         addAttribute("VGCLabels.total.tenured.heap.before.gc", "total", 
/* 708 */           atts, this.currentComment);
/*     */       }
/* 710 */     } else if ("soa".equals(type)) {
/* 711 */       addAttribute("VGCLabels.free.soa.before.collection", "free", atts, 
/* 712 */         this.currentComment);
/* 713 */       addAttribute("VGCLabels.total.soa.before", "total", atts, 
/* 714 */         this.currentComment);
/* 715 */     } else if ("loa".equals(type)) {
/* 716 */       addAttribute("VGCLabels.free.loa.before.collection", "free", atts, 
/* 717 */         this.currentComment);
/* 718 */       addAttribute("VGCLabels.total.loa.before", "total", atts, 
/* 719 */         this.currentComment);
/* 720 */     } else if ("eden".equals(type)) {
/* 721 */       addAttribute("VGCLabels.eden.size", "total", atts, this.currentComment);
/* 722 */       addAttribute("VGCLabels.free.eden", "free", atts, this.currentComment);
/*     */     }
/*     */   }
/*     */ 
/*     */   private void handleCopyFailed(String name, Attributes atts) {
/* 727 */     String type = atts.getValue("type");
/* 728 */     if ("nursery".equals(type)) {
/* 729 */       addAttribute("VGCLabels.amount.failed.flipped", "bytes", atts);
/* 730 */       addAttribute("VGCLabels.objects.failed.flipped", "objects", atts);
/* 731 */     } else if ("tenure".equals(type)) {
/* 732 */       addAttribute("VGCLabels.amount.failed.tenured", "bytes", atts);
/* 733 */       addAttribute("VGCLabels.objects.failed.tenured", "objects", atts);
/*     */     }
/*     */   }
/*     */ 
/*     */   private void handleMemoryCopied(String name, Attributes atts)
/*     */   {
/* 739 */     String type = atts.getValue("type");
/* 740 */     if ("nursery".equals(type)) {
/* 741 */       addAttribute("VGCLabels.amount.flipped", "bytes", atts);
/* 742 */       addAttribute("VGCLabels.objects.flipped", "objects", atts);
/* 743 */     } else if ("tenure".equals(type)) {
/* 744 */       this.createdAmountTenured = true;
/* 745 */       addAttribute("VGCLabels.amount.tenured", "bytes", atts);
/* 746 */       addAttribute("VGCLabels.objects.tenured", "objects", atts);
/* 747 */     } else if ("eden".equals(type)) {
/* 748 */       addAttribute("VGCLabels.amount.copied.eden", "bytes", atts);
/* 749 */       addAttribute("VGCLabels.objects.copied.eden", "objects", atts);
/* 750 */     } else if ("other".equals(type)) {
/* 751 */       addAttribute("VGCLabels.amount.copied.other", "bytes", atts);
/* 752 */       addAttribute("VGCLabels.objects.copied.other", "objects", atts);
/*     */     }
/*     */   }
/*     */ 
/*     */   private void handleDuration(String name, Attributes atts) {
/* 757 */     double duration = convertStringToNumber(atts.getValue("duration")) / 
/* 758 */       1000.0D;
/* 759 */     if (this.inCardCleaning)
/* 760 */       this.dataManager.addPoint("VGCLabels.card.cleaning.times", duration, 
/* 761 */         this.currentComment);
/*     */   }
/*     */ 
/*     */   private void handleCardCleaning(String name, Attributes atts)
/*     */   {
/* 766 */     addAttribute("VGCLabels.cards.cleaned", "cardsCleaned", atts);
/* 767 */     addAttribute("VGCLabels.cards.traced", "bytesTraced", atts);
/*     */   }
/*     */ 
/*     */   private void handleKickoff(String name, Attributes atts) {
/* 771 */     addAttribute("VGCLabels.intended.kickoff", "thresholdFreeBytes", atts);
/* 772 */     addAttribute("VGCLabels.trace.target", "targetBytes", atts);
/*     */   }
/*     */ 
/*     */   private void handleResponseInfo(String name, Attributes atts) {
/* 776 */     this.accessTime = convertStringToNumber(atts.getValue("timems"));
/*     */   }
/*     */ 
/*     */   protected double convertStringToNumber(String stringValue) {
/* 780 */     double value = -1.0D;
/*     */ 
/* 782 */     if ((stringValue != null) && (stringValue.length() > 0)) {
/*     */       try {
/* 784 */         value = Double.parseDouble(stringValue);
/*     */       } catch (NumberFormatException localNumberFormatException) {
/* 786 */         value = J926DateConverter.parseDate(stringValue);
/*     */       }
/*     */     }
/* 789 */     return value;
/*     */   }
/*     */ 
/*     */   private void handleCompactInfo(String name, Attributes atts) {
/* 793 */     String comment = atts.getValue("reason");
/* 794 */     if (comment != null) {
/* 795 */       addAttribute("VGCLabels.amount.compacted", "movebytes", atts, comment);
/* 796 */       addAttribute("VGCLabels.objects.compacted", "movecount", atts, comment);
/*     */     } else {
/* 798 */       addAttribute("VGCLabels.amount.compacted", "movebytes", atts);
/* 799 */       addAttribute("VGCLabels.objects.compacted", "movecount", atts);
/*     */     }
/*     */   }
/*     */ 
/*     */   private void handleReferences(String name, Attributes atts) {
/* 804 */     String type = atts.getValue("type");
/*     */ 
/* 806 */     if ("weak".equals(type)) {
/* 807 */       addAttribute("VGCLabels.weak.references.cleared", "cleared", atts);
/* 808 */       String before = atts.getValue("candidates");
/*     */ 
/* 810 */       if (before != null) {
/* 811 */         addAttribute("VGCLabels.weak.references.before.collection", "candidates", atts);
/*     */ 
/* 813 */         double weakAfter = this.dataManager
/* 814 */           .getLastValue("VGCLabels.weak.references.before.collection") - 
/* 815 */           this.dataManager
/* 816 */           .getLastValue("VGCLabels.weak.references.cleared");
/* 817 */         addDataPoint("VGCLabels.weak.references.after.collection", weakAfter, 
/* 818 */           this.currentComment);
/*     */       }
/* 820 */     } else if ("soft".equals(type)) {
/* 821 */       addAttribute("VGCLabels.soft.references.cleared", "cleared", atts);
/* 822 */       String before = atts.getValue("candidates");
/*     */ 
/* 824 */       if (before != null) {
/* 825 */         addAttribute("VGCLabels.soft.references.before.collection", "candidates", atts);
/*     */ 
/* 827 */         double softAfter = this.dataManager
/* 828 */           .getLastValue("VGCLabels.soft.references.before.collection") - 
/* 829 */           this.dataManager
/* 830 */           .getLastValue("VGCLabels.soft.references.cleared");
/* 831 */         addDataPoint("VGCLabels.soft.references.after.collection", softAfter, 
/* 832 */           this.currentComment);
/* 833 */         addAttribute("VGCLabels.dynamic.soft.reference.threshold", 
/* 834 */           "dynamicThreshold", atts);
/* 835 */         addAttribute("VGCLabels.max.soft.reference.threshold", 
/* 836 */           "maxThreshold", atts);
/*     */       }
/* 838 */     } else if ("phantom".equals(type)) {
/* 839 */       addAttribute("VGCLabels.phantom.references.cleared", "cleared", atts);
/* 840 */       String before = atts.getValue("candidates");
/*     */ 
/* 842 */       if (before != null) {
/* 843 */         addAttribute("VGCLabels.phantom.references.before.collection", "candidates", 
/* 844 */           atts);
/*     */ 
/* 846 */         double phantomAfter = this.dataManager
/* 847 */           .getLastValue("VGCLabels.phantom.references.before.collection") - 
/* 848 */           this.dataManager
/* 849 */           .getLastValue("VGCLabels.phantom.references.cleared");
/* 850 */         addDataPoint("VGCLabels.phantom.references.after.collection", phantomAfter, 
/* 851 */           this.currentComment);
/*     */       }
/*     */     }
/*     */   }
/*     */ 
/*     */   private void handleGCOP(String name, Attributes atts) {
/* 857 */     this.isGoodData = true;
/* 858 */     String type = atts.getValue("type");
/*     */ 
/* 860 */     if ("mark".equals(type)) {
/* 861 */       addAttribute("VGCLabels.mark.times", "timems", atts);
/* 862 */     } else if ("sweep".equals(type)) {
/* 863 */       addAttribute("VGCLabels.sweep.times", "timems", atts);
/* 864 */     } else if ("compact".equals(type)) {
/* 865 */       addAttribute("VGCLabels.compact.times", "timems", atts);
/* 866 */     } else if ("classunload".equals(type)) {
/* 867 */       addAttribute("VGCLabels.class.unloading.time", "timems", atts);
/* 868 */     } else if ("copy forward".equals(type)) {
/* 869 */       addAttribute("VGCLabels.copy.forward.time", "timems", atts);
/* 870 */     } else if ("scavenge".equals(type)) {
/* 871 */       this.inScavenge = true;
/* 872 */       addAttribute("VGCLabels.scavenge.time", "timems", atts);
/* 873 */     } else if ("syncgc".equals(type)) {
/* 874 */       this.syncDuration = convertStringToNumber(atts.getValue("timems"));
/* 875 */       addAttribute("WRTLabels.synch.gc.durations", "timems", atts);
/*     */     }
/* 879 */     else if ("heartbeat".equals(type)) {
/* 880 */       addDataPoint("WRTLabels.gc.activity", WRTEvents.nameToInt(type), 
/* 881 */         this.currentComment);
/*     */     }
/*     */   }
/*     */ 
/*     */   private void handleSysStart(String name, Attributes atts) {
/* 886 */     this.currentReason = VGCGCReasons.SYS_INT;
/* 887 */     this.triggeredInterval = convertStringToNumber(atts.getValue("intervalms"));
/*     */   }
/*     */ 
/*     */   private void handleAFStart(String name, Attributes atts) {
/* 891 */     this.bytesRequested = convertStringToNumber(atts.getValue("totalBytesRequested"));
/* 892 */     this.currentReason = VGCGCReasons.AF_INT;
/* 893 */     this.triggeredInterval = convertStringToNumber(atts.getValue("intervalms"));
/*     */   }
/*     */ 
/*     */   private void handleAllocationTaxation(String name, Attributes atts) {
/* 897 */     this.currentReason = VGCGCReasons.BAL_INT;
/* 898 */     this.triggeredInterval = convertStringToNumber(atts.getValue("intervalms"));
/*     */   }
/*     */ 
/*     */   private void handleExclusiveEnd(String name, Attributes atts)
/*     */   {
/* 903 */     if (this.hadGCStart) {
/* 904 */       double pauseTime = convertStringToNumber(atts.getValue("durationms"));
/* 905 */       addDataPoint("VGCLabels.pause.times.with.exclusive.access", 
/* 906 */         pauseTime, this.currentComment);
/* 907 */       this.hadGCStart = false;
/*     */     }
/*     */   }
/*     */ 
/*     */   protected void initialiseSpecificSourceData(OutputProperties properties) {
/*     */   }
/*     */ 
/*     */   private void writeOutSourceData() {
/* 915 */     if ((this.version != null) && 
/* 916 */       (this.version.indexOf("-Metronome") >= 0)) {
/* 917 */       this.isGoodData = false;
/*     */     }
/* 919 */     if (!this.gcAttributes.isEmpty()) {
/* 920 */       this.sourceData.addData(this.gcAttributes, DataLevel.VARIANT);
                //added by wenguang.huang 
                this.sourceData.addData(this.gcAttributes, DataLevel.DATASET);
				//added end by wenguang.huang 


/*     */     }
/* 922 */     if (!this.systemAttributes.isEmpty()) {
/* 923 */       this.sourceData.addData(this.systemAttributes, DataLevel.VARIANT);
                //added by wenguang.huang 
                this.sourceData.addData(this.systemAttributes, DataLevel.DATASET);
				//added end by wenguang.huang 
/*     */     }
/* 925 */     if (this.isGoodData) {
/* 926 */       if (this.restartCount > 0) {
/* 927 */         String message = MessageFormat.format(
/* 928 */           VM_RESTART_WARNING_CONTENTS, 
/* 929 */           new Object[] { Integer.valueOf(this.restartCount) });
/* 930 */         UnstructuredData restarts = factory.createUnstructuredData(
/* 931 */           "VGCLabels.restart.warning", 
/* 932 */           Messages.getString("VGCLabels.restart.warning"), message);
/* 933 */         this.sourceData.addData(restarts, DataLevel.VARIANT);
                  //added by wenguang.huang 
                  this.sourceData.addData(restarts, DataLevel.DATASET);
                  //added end by wenguang.huang 
/*     */       }
/*     */ 
/* 936 */       if (this.version == null)
/*     */       {
/* 939 */         this.version = "IBM J9 ";
/*     */       }
/* 941 */       recordVersion();
/*     */ 
/* 943 */       this.dataManager.complete();
/*     */     }
/*     */   }
/*     */ }

